using System;

namespace Demo
{
    internal static class DatabaseConfig
    {
        private const string DefaultConnectionString =
            "Server=127.0.0.1;Port=3306;Database=CognitiveTestDB;Uid=root;Pwd=root;Charset=utf8mb4;Allow User Variables=True;";

        internal static string ConnectionString { get; } = ResolveConnectionString();

        private static string ResolveConnectionString()
        {
            var fromEnvironment = Environment.GetEnvironmentVariable("COGNITIVE_TEST_CONN");
            return string.IsNullOrWhiteSpace(fromEnvironment)
                ? DefaultConnectionString
                : fromEnvironment;
        }
    }
}

